package com.example.teamwork.Controller;

import com.example.teamwork.Shrio.Bean.ResponseBean;
import com.example.teamwork.service.MailService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author  SongPeng
 * @date  2021/11/21 15:41
 * @version 1.0
 */


@RestController
@RequestMapping("/Mail")
public class MailController {
    @ModelAttribute
    public void doString(){
        MDC.put("operateModuleName","发送邮件模块");
    }
    @Autowired
    private MailService mailService;
    /**
     * 审核通过发送普通邮件
     */
    @RequiresPermissions("order:pass")
    @PostMapping("{orderId}/post")
    public ResponseBean sendSimpleMailMessage(@PathVariable("orderId") Long orderId) {
        mailService.sendSimpleMailMessge(orderId);
        return ResponseBean.success();
    }
    /**
     *
     * 审核拒绝
     * */
    @RequiresPermissions("order:reject")
    @RequestMapping("{orderId}/reject")
    public ResponseBean sendHtmlMessage(@PathVariable("orderId") Long orderId) {
        mailService.sendMimeMessge(orderId);
        return ResponseBean.success();
    }
}


